package com.qipay.baas.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.qipay.baas.model.ActionDocDetail;

public class ActionDocDetailSqlProvider {

    public String insertSelective(ActionDocDetail record) {
        BEGIN();
        INSERT_INTO("action_doc_detail");
        
        if (record.getDocId() != null) {
            VALUES("doc_id", "#{docId,jdbcType=INTEGER}");
        }
        
        if (record.getTitle() != null) {
            VALUES("title", "#{title,jdbcType=VARCHAR}");
        }
        
        if (record.getPid() != null) {
            VALUES("pid", "#{pid,jdbcType=INTEGER}");
        }
        
        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getParntCateName() != null) {
            VALUES("parnt_cate_name", "#{parntCateName,jdbcType=VARCHAR}");
        }
        
        if (record.getInfo() != null) {
            VALUES("info", "#{info,jdbcType=LONGVARCHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(ActionDocDetail record) {
        BEGIN();
        UPDATE("action_doc_detail");
        
        if (record.getDocId() != null) {
            SET("doc_id = #{docId,jdbcType=INTEGER}");
        }
        
        if (record.getTitle() != null) {
            SET("title = #{title,jdbcType=VARCHAR}");
        }
        
        if (record.getPid() != null) {
            SET("pid = #{pid,jdbcType=INTEGER}");
        }
        
        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getParntCateName() != null) {
            SET("parnt_cate_name = #{parntCateName,jdbcType=VARCHAR}");
        }
        
        if (record.getInfo() != null) {
            SET("info = #{info,jdbcType=LONGVARCHAR}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}